﻿using Inovout.Cloud.Applications.Models;
using Inovout.Cloud.Applications.Security.Models;
using Inovout.Cloud.Applications.Security.Repositories;
using Inovout.Security;
using Inovout.Services;
using NHibernate.Criterion;

namespace Inovout.Cloud.Applications.Security.Services
{
    public class ApplicationUserService : RepositoryService<ApplicationUser>, IApplicationUserService
    {
        private ApplicationUserRepository ApplicationUserRepository
        {
            get { return (ApplicationUserRepository)base.Repository; }
        }
        public ApplicationUser FindByName(string name)
        {
            return base.Repository.Find(Restrictions.Eq("Name", name).IgnoreCase());
        }
        public ApplicationUser FindBySystemUser(ISystemUser user)
        {
            return base.Repository.Find(Restrictions.Eq("OwnerUser.Id", (object)((SystemUser)user).Id));
        }

        public ApplicationUser FindByApplication(Application application)
        {
            return base.Repository.Find(Restrictions.Eq("Application.Id", (object)application.Id));
        }


    }
}
